package samples.examples.video_test.application ;
import js.Dom ;
import divtastic.js.DisplayDiv ;
import divtastic.js.application.views.WindowView ;
import haxe.Timer;
//https://developer.mozilla.org/En/Manipulating_video_using_canvas




class Controller
{
    
    
    private var _holder :   DisplayDiv;
    
    private var div1:       DisplayDiv;
    private var div2:       DisplayDiv;
    private var div3:       DisplayDiv;
    
    
    
    public function new( holder_: DisplayDiv )
    {
        
        _holder                     = holder_ ;
           div1                        = new DisplayDiv( 'big_buck_bunny.webm') ;
        div1.x                      = 0;
        div1.y                      = 0;
        div1.width                  = 10;
        div1.height                 = 10;
        _holder.addChild( div1 ) ;
        div1.play();
        div1.getStyle().position    = 'absolute';
        
        div2                        = new DisplayDiv('canvas');
        div2.fill                   = '#ff0000';
        div2.x                      = 600;
        div2.y                      = 0;
        div2.width                  = 0;
        div2.height                 = 0;
        div2.getStyle().position    = 'absolute';
        _holder.addChild( div2 ) ;
        
        var atimer = new Timer( 40 );
        atimer.run = copyAcross;
        
    }
    
    
    public function copyAcross()
    {
        
        var image: Image = cast div1.getInstance();
        
        div2.twoD.drawImage( image, 0, 0, 600, 600 ); 
        
    }
    
}